import Cookies from 'js-cookie'

const TokenKey = 'tofu-systems-token'

/**
 * 验证是否有权限
 */
export function isAuth(username) {
	return username !== ''
}

/**
 * 移除token
 */

export function removeUserToken() {
	return Cookies.remove(TokenKey)
}

/**
 * 设置token
 * 过期时间是当前时间往后的1小时
 */

export function setUserToken(token) {
	let date = new Date()
	date = date.setDate(date.getHours() + 1)
	return Cookies.set(TokenKey, token, {
		expires: date
	})
}

/**
 * 获取token
 */

export function getUserToken() {
	return Cookies.get(TokenKey)
}
